package com.umeox.watch.moto.chat.base

import android.content.Context
import android.os.Build
import androidx.multidex.MultiDex
import androidx.multidex.MultiDexApplication

import com.tencent.bugly.crashreport.CrashReport
import com.tencent.bugly.crashreport.CrashReport.UserStrategy
import com.tencent.mmkv.MMKV
import com.umeox.moto.common.log.Logger
import com.umeox.moto.common.utils.AndroidUtils
import com.umeox.watch.moto.chat.BuildConfig
import com.umeox.watch.moto.chat.R
import com.umeox.watch.moto.dataservice.DataProvider
import uk.co.chrisjenx.calligraphy.CalligraphyConfig

/**
 * Created by Rambo 2021/8/18
 * Describe:
 */
class BaseApp : MultiDexApplication() {

    companion object {
        private var appContext: Context? = null
        fun getContext(): Context {
            return appContext as Context
        }
    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        appContext = this
        Logger.d(">>>>>>>>>device_launcher chat BaseApp attachBaseContext<<<<<<<<<")
    }

    override fun onCreate() {
        Logger.d(">>>>>>>>> Chat BaseApp onCreate<<<<<<<<<")
        super.onCreate()
        MultiDex.install(this)
        DataProvider.initialize(this)
        MMKV.initialize(this)
        val userStrategy = UserStrategy(this)
        userStrategy.appChannel = BuildConfig.FLAVOR + "-" + AndroidUtils.getDeviceId()
        CrashReport.initCrashReport(this, "a018aa68d5", false, userStrategy)

        CalligraphyConfig.initDefault(
            CalligraphyConfig.Builder()
                .setDefaultFontPath("fonts/Roboto-Medium.ttf")
                .setFontAttrId(R.attr.fontPath)
                .build()
        )

    }
}